package com.shangbang.verb.controller.recruit;

import com.shangbang.verb.core.BaseResponse;
import com.shangbang.verb.service.recruit.WorkService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Api(value = "招聘者操作简历类接口", tags = "发布简历相关接口", description = "发布简历的新增、更新")

@RestController
@RequestMapping(value = "/recruit/work")
public class WorkController {

    @Autowired
    private WorkService workService;

    /**
     * 发布招聘
     * @param request
     * @param response
     * @param uid
     * @param position
     * @param introduction
     * @param claim
     * @param welfare
     * @param salary
     * @param workType
     * @param phone
     * @param enterpriseName
     * @param place
     * @param lat
     * @param img
     * @param lng
     * @return
     */
    @ApiOperation(value = "发布者创建简历接口",notes = "")
    @ApiResponses({ @ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = -1, message = "操作失败") })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", required = true, dataType = "int"),
            @ApiImplicitParam(name = "position", value = "职位名称", required = true, dataType = "String"),
            @ApiImplicitParam(name = "introduction", value = "职位描述", required = true, dataType = "String"),
            @ApiImplicitParam(name = "claim", value = "开发年限", required = true, dataType = "String"),
            @ApiImplicitParam(name = "welfare", value = "五险一金", required = true, dataType = "String"),
            @ApiImplicitParam(name = "salary", value = "薪资待遇", required = true, dataType = "String"),
            @ApiImplicitParam(name = "workType", value = "招聘类型", required = true, dataType = "String"),
            @ApiImplicitParam(name = "phone", value = "手机", required = true, dataType = "String"),
            @ApiImplicitParam(name = "enterpriseName", value = "公司名称", required = true, dataType = "String"),
            @ApiImplicitParam(name = "place", value = "公司地址", required = true, dataType = "String"),
            @ApiImplicitParam(name = "lat", value = "精度", required = true, dataType = "String"),
            @ApiImplicitParam(name = "img", value = "图片地址", required = true, dataType = "String"),
            @ApiImplicitParam(name = "lng", value = "维度", required = true, dataType = "String")
    })
    @RequestMapping(value = "/createWorkInfo", method = {RequestMethod.POST, RequestMethod.GET})
    public BaseResponse createWorkInfo(HttpServletRequest request, HttpServletResponse response,
                                 @RequestParam(required = true) Integer uid,
                                 @RequestParam(required = true) String position,
                                 @RequestParam(required = true) String introduction,
                                   @RequestParam(required = true) String claim,
                                   @RequestParam(required = true) String welfare,
                                   @RequestParam(required = true) String salary,
                                   @RequestParam(required = true) String workType,
                                   @RequestParam(required = true) String phone,
                                   @RequestParam(required = true) String enterpriseName,
                                   @RequestParam(required = true) String place,
                                   @RequestParam(required = true) String lat,
                                   @RequestParam(required = true) String img,
                                   @RequestParam(required = true) String lng) {
        Object result = "";
        Integer code = 0;
        String msg = "成功";

        result =  workService.createWorkInfo(uid,position,introduction,claim,welfare,salary,workType,phone,enterpriseName,place,lat,img,lng);


        return new BaseResponse(code, msg, result);
    }
    @ApiOperation(value = "发布者获取简历列表",notes = "")
    @ApiResponses({ @ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = -1, message = "操作失败") })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "第几页", required = true, dataType = "int"),
            @ApiImplicitParam(name = "num", value = "多少条", required = true, dataType = "int")
    })
    @RequestMapping(value = "/getWorkList", method = {RequestMethod.POST, RequestMethod.GET})
    public BaseResponse getWorkList(HttpServletRequest request, HttpServletResponse response,
                                       @RequestParam(required = true) Integer page,
                                       @RequestParam(required = true) Integer num) {
        Object result = "";
        Integer code = 0;
        String msg = "成功";

        result =  workService.getWorkList((page-1)*num,num);


        return new BaseResponse(code, msg, result);
    }


}
